package panel.eating
{
	import assists.Lang;
	import assists.URI;
	import assists.resource.ResourceLoader;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	
	public class NiMaContainer extends Sprite
	{
		private var _stage:Stage;
		private var _loader:ResourceLoader;
		private var _lang:Lang;
		private var _uri:URI;
		
		private var thisList:Array;
		
		public function NiMaContainer(stage:Stage, loader:ResourceLoader, lang:Lang, uri:URI)
		{
			_stage = stage;
			_loader = loader;
			_lang = lang;
			_uri = uri;
			
			thisList = [];
		}
		
		public function changeData(list:Array):void
		{
			clearAll();
			
			for(var i:int = 0;i < list.length;i++){
				thisList.push(list[i]);
			}
			
			addContent();
		}
		
		private function addContent():void
		{
			var loc:Number = 0;
			for(var i:int = 0;i < thisList.length;i++){
				thisList[i].x = 0;
				thisList[i].y = loc;
				
				this.addChild(thisList[i]);
				
				loc = loc + thisList[i].height;
			}
		}
		
		private function clearAll():void
		{
			for(var i:int =0;i < thisList.length;i++){
				removeChild(thisList[i]);
			}
			
			thisList = [];
		}
		
		public function clear():void
		{
			_stage = null;
			_loader = null;
			_lang = null;
			_uri = null;
			
			clearAll();
		}
		
//		public override function get height():Number
//		{
//			var num:Number = 0;
//			for(var i:int = 0;i < thisList.length;i++){
//				num = num + thisList[i].height;
//			}
//			
//			return num;
//		}
	}
}